package com.chhh.cranelease.service.impl;

import com.chhh.cranelease.entity.CarLog;
import com.chhh.cranelease.entity.Parts;
import com.chhh.cranelease.mapper.BusinessManageMapper;
import com.chhh.cranelease.mapper.IntegratedmanageMapper;
import com.chhh.cranelease.model.CarLogModel;
import com.chhh.cranelease.service.BusinessManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BusinessManageServiceImp implements BusinessManageService {



    @Autowired
    private BusinessManageMapper businessManageMapper;

    @Autowired
    private IntegratedmanageMapper integratedmanageMapper;
    // 出行记录
    @Override
    public Integer updateCarLog(CarLog carLog) {
        if(carLog.getCl_state()==3){
            integratedmanageMapper.insertRepair(carLog);
        }
      return businessManageMapper.updateCarLog(carLog);
    }

    @Override
    public Integer insertCarLog(CarLog carLog) {
        if(carLog.getCl_state()==3){
            integratedmanageMapper.insertRepair(carLog);
        }
        return businessManageMapper.insertCarLog(carLog);
    }

    @Override
    public List<CarLogModel> selectAllUseCar(String cl_num, String cl_name, String cl_outtime, String cl_days, String cl_company) {
        return businessManageMapper.selectAllUseCar(cl_num,cl_name,cl_outtime,cl_days,cl_company);
    }


    // 配件管理
    @Override
    public List<Parts> selectAllParts(String p_date, String p_des, String p_num) {
        return businessManageMapper.selectAllParts(p_date,p_des,p_num);
    }

    @Override
    public Integer insertParts(Parts parts) {
        return businessManageMapper.insertParts(parts);
    }

    @Override
    public Integer updateParts(Parts parts) {
        return businessManageMapper.updateParts(parts);
    }

    @Override
    public Integer deleteParts(Integer[] p_id) {
        return businessManageMapper.deleteParts(p_id);
    }
}
